#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;

void bbs(int list[], int listl) {
    while(listl--)    {
        bool swapp = false;

        for(int i = 0 ;i < listl; i++) {
                if(list[i] > list[i + 1]){
                    swap(list[i], list[i + 1]);
                    swapp = true;
                }
        }

        if(swapp == false) break;
    }
}

void rff(const char *fn, int a[], int l) {
    ifstream file(fn);

    for(int i = 0; i < l; i++)
    file >> a[i];
}

int main()
{
    #define LEN 5000
    int a[LEN];

    rff("m1_sorted.txt",a,LEN);
    unsigned int ts = clock();
    bbs(a,LEN);
    unsigned int tf = clock();
    unsigned int twork = tf - ts;
    cout<<"m1_sorted " << twork << " milliseconds \n";

    rff("m2_reverse.txt",a,LEN);
    unsigned int ts2 = clock();
    bbs(a,LEN);
    unsigned int tf2 = clock();
    unsigned int twork2 = tf2 - ts2;
    cout<<"m2_reverse " << twork << " milliseconds \n";

    rff("m3_shuffle.txt",a,LEN);
    unsigned int ts3 = clock();
    bbs(a,LEN);
    unsigned int tf3 = clock();
    unsigned int twork3 = tf3 - ts3;
    cout<<"m3_shuffle " << twork << " milliseconds \n";

    return 0;
}
